package communication.game;

import server.ServerInternals;
import game.MagicObject;
import game.ServersideGame;
import communication.*;
import java.awt.Point;

/**
 * Indique qu'une case de la partie est jouee
 * @author Roch Julien
 * @version 1.0
 */
public class PlayCell extends ComCliSrv {

	/**
	 * Pour la serialisation
	 */
	private static final long serialVersionUID = -3380266849438276370L;
	private int gameId;
	private Point point;
	private MagicObject object = null;
	/**
	 * 
	 * @param gameId identifiant de la partie
	 * @param point Coordonees de la case
	 */
	public PlayCell(int gameId, Point point){
		this.gameId = gameId;
		this.point = point;
	}
	/**
	 * 
	 * @param gameId identifiant de la partie
	 * @param point Coordonees de la case
	 * @param magicObject objet magique a jouer
	 */
	public PlayCell(int gameId, Point point, MagicObject magicObject){
		this(gameId,point);
		this.object = magicObject;
	}
	

	
	@Override
	public void handleServerInternals(ServerInternals internals) {
		// Recup la partie
		ServersideGame game = internals.getGame(gameId);
		// Recup le nom du client
		String user = internals.getClients().get(socket);
		// Joue
		game.playCell(point, user, object);
	}

}
